package testing;

import bitetorrent.MyThread;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.util.logging.Level;
import java.util.logging.Logger;

public class ServerThread extends MyThread {

    Socket s = null;
    int id = 0;
    OutputStream out;

    public ServerThread(Socket s, int id) {
        this.s = s;
        this.id = id;
        try {
            out = s.getOutputStream();
        } catch (IOException ex) {
            Logger.getLogger(ServerThread.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    @Override
    public void run() {
        for (int i = 0; i < 10; ++i) {
            try {
                String str = "i : " + i + ", count : " + id +"\n";
                out.write(str.getBytes());
                Thread.sleep(1000);
            } catch (IOException ex) {
                Logger.getLogger(ServerThread.class.getName()).log(Level.SEVERE, null, ex);
            } catch (InterruptedException ex) {
                Logger.getLogger(ServerTCP.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
}
